package com.meilai.project.dto.personnel.onTurn;

import com.meilai.project.entity.personnel.onTurn.TransferApplyNewDep;
import com.meilai.project.entity.personnel.onTurn.TransferApplyOldDep;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xchen
 * @since 2022-01-26
 */
@Data
@ApiModel
public class TransferApplyDeptDTO {

    @ApiModelProperty(value = "部门id")
    private Long id;

    @ApiModelProperty(value = "部门名称")
    private String department;

    @ApiModelProperty(value = "职位")
    private String job;

    @ApiModelProperty(value = "是否为主部门")
    private Boolean main;

    @ApiModelProperty(value = "是否为业务负责人")
    private Boolean business_head;

    public static TransferApplyDeptDTO parseNew(TransferApplyNewDep dep) {
        TransferApplyDeptDTO transferApplyDeptDTO = new TransferApplyDeptDTO();
        transferApplyDeptDTO.setId(dep.getDepartment_id());
        transferApplyDeptDTO.setDepartment(dep.getDepartment());
        transferApplyDeptDTO.setJob(dep.getJob());
        transferApplyDeptDTO.setMain(dep.getMain());
        transferApplyDeptDTO.setBusiness_head(dep.getBusiness_head());
        return transferApplyDeptDTO;
    }

    public static List<TransferApplyDeptDTO> parseNew(List<TransferApplyNewDep> depList) {
        List<TransferApplyDeptDTO> result = new ArrayList<>();
        if(null == depList) {
            return result;
        }
        for (TransferApplyNewDep transferApplyDep : depList) {
            result.add(parseNew(transferApplyDep));
        }
        return result;
    }

    public static TransferApplyDeptDTO parseOld(TransferApplyOldDep dep) {
        TransferApplyDeptDTO transferApplyDeptDTO = new TransferApplyDeptDTO();
        transferApplyDeptDTO.setId(dep.getDepartment_id());
        transferApplyDeptDTO.setDepartment(dep.getDepartment());
        transferApplyDeptDTO.setJob(dep.getJob());
        transferApplyDeptDTO.setMain(dep.getMain());
        transferApplyDeptDTO.setBusiness_head(dep.getBusiness_head());
        return transferApplyDeptDTO;
    }

    public static List<TransferApplyDeptDTO> parseOld(List<TransferApplyOldDep> depList) {
        List<TransferApplyDeptDTO> result = new ArrayList<>();
        if(null == depList) {
            return result;
        }
        for (TransferApplyOldDep transferApplyDep : depList) {
            result.add(parseOld(transferApplyDep));
        }
        return result;
    }

    public static TransferApplyOldDep toOld(Long pId, TransferApplyDeptDTO dto) {
        TransferApplyOldDep transferApplyOldDep = new TransferApplyOldDep();
        transferApplyOldDep.setPid(pId);
        transferApplyOldDep.setDepartment_id(dto.getId());
        transferApplyOldDep.setDepartment(dto.getDepartment());
        transferApplyOldDep.setJob(dto.getJob());
        transferApplyOldDep.setMain(dto.getMain());
        transferApplyOldDep.setBusiness_head(dto.getBusiness_head());
        return transferApplyOldDep;
    }

    public static List<TransferApplyOldDep> toOld(Long pId, List<TransferApplyDeptDTO> list) {
        List<TransferApplyOldDep> result = new ArrayList<>();
        for (TransferApplyDeptDTO transferApplyDeptDTO : list) {
            result.add(toOld(pId, transferApplyDeptDTO));
        }
        return result;
    }

    public static TransferApplyNewDep toNew(Long pId, TransferApplyDeptDTO dto) {
        TransferApplyNewDep transferApplyOldDep = new TransferApplyNewDep();
        transferApplyOldDep.setPid(pId);
        transferApplyOldDep.setDepartment_id(dto.getId());
        transferApplyOldDep.setDepartment(dto.getDepartment());
        transferApplyOldDep.setJob(dto.getJob());
        transferApplyOldDep.setMain(dto.getMain());
        transferApplyOldDep.setBusiness_head(dto.getBusiness_head());
        return transferApplyOldDep;
    }

    public static List<TransferApplyNewDep> toNew(Long pId, List<TransferApplyDeptDTO> list) {
        List<TransferApplyNewDep> result = new ArrayList<>();
        for (TransferApplyDeptDTO transferApplyDeptDTO : list) {
            result.add(toNew(pId, transferApplyDeptDTO));
        }
        return result;
    }

}
